﻿<Page x:Class="MyCalManager.View.MainContent"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:Helper="clr-namespace:MyCalManager.Helper"
      xmlns:igDP="http://infragistics.com/DataPresenter" 
      mc:Ignorable="d" 
      d:DesignHeight="600" d:DesignWidth="950"
	  DataContext="{Binding MainContent, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/MainSkin.xaml" />
                <ResourceDictionary Source="/Skins/Theme.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Margin="3" BorderBrush="GhostWhite" BorderThickness="1" CornerRadius="10">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" Margin="3">
                    <Helper:InfoTextBox MaxWidth="350" Margin="6,3,3,3" Width="{Binding ElementName=Col1, Path=Width}" Text="{Binding SearchFood, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" InputType="Text" TextBoxInfo="{Loc searchTextBox}" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" TabIndex="2"></Helper:InfoTextBox>
                    <Helper:InfoTextBox Text="{Binding Amount,Mode=TwoWay}" IsValid="{Binding Valid, Mode=TwoWay}" InputType="IntNotNull" TextBoxInfo="{Loc amountTxtBox}" Width="100" Margin="3" ></Helper:InfoTextBox>
                    <Label HorizontalAlignment="Center" VerticalAlignment="Center" Content="g"></Label>
                    <Button Command="{Binding Add}" Content="{Loc EinfügenBtnToolTip}" Width="70" Margin="3"></Button>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="1" Grid.Row="0" Margin="3">
                    <ComboBox MinWidth="120" Margin="2" ItemsSource="{Binding ListOfDay}" SelectedValuePath="StringTimekey" SelectedItem="{Binding selectedDay,Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Margin="2" Text="{Binding Path=StringTimekey}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <Button Command="{Binding NewDay}" Margin="3" ToolTip="{Loc newDayBtnTxt}" Width="25" Height="25">
                        <Button.Content>
                            <Image Source="pack://application:,,,/Images/Calendar.ico"></Image>
                        </Button.Content>
                    </Button>
                </StackPanel>
               
                    <ListView Grid.Row="2"
                              Margin="6,6,6,1"
                              Grid.ColumnSpan="2"
                              IsSynchronizedWithCurrentItem="True"
                              ItemsSource="{Binding Foods.View}" 
                              SelectedItem="{Binding SelectedFood, Mode=TwoWay}" 
                              SelectionMode="Single"
                              SelectionChanged="ListView_SelectionChanged">
                        <ListView.View>
                            <GridView AllowsColumnReorder="False">
                                <GridViewColumn x:Name="Col1" Header="{Loc NahrungsmittelLbl}"  Width="170" DisplayMemberBinding="{Binding Item}"></GridViewColumn>
                                <GridViewColumn x:Name="Col2" Header="KCal"  Width="60" DisplayMemberBinding="{Binding Kcal}"></GridViewColumn>
                                <GridViewColumn x:Name="Col3" Header="{Loc FettLbl}"  Width="60" DisplayMemberBinding="{Binding Fat}"></GridViewColumn>
                                <GridViewColumn x:Name="Col4" Header="{Loc KhLbl}"  Width="60" DisplayMemberBinding="{Binding Kh}"></GridViewColumn>
                                <GridViewColumn x:Name="Col5" Header="{Loc EiweißLbl}"  Width="60" DisplayMemberBinding="{Binding Carbs}"></GridViewColumn>
                                <GridViewColumn x:Name="Col6" Header="{Loc RubrikLbl}"  Width="150" DisplayMemberBinding="{Binding Category}"></GridViewColumn>
                                <GridViewColumn x:Name="Col7" Header="WWPoints"  Width="60" DisplayMemberBinding="{Binding WWPoints}"></GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>
                <Helper:Reveal IsExpanded="{Binding FoodEditVisibility}" Margin="5,0,3,3" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left">
                    <StackPanel  Orientation="Horizontal" >
                        <Helper:InfoTextBox Text="{Binding Item, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding ItemValid,Mode=TwoWay}" InputType="TextNotNull" Margin="1,0,0,0" TextBoxInfo="{Loc NahrungsmittelLbl}" Width="{Binding ElementName=Col1, Path=Width}" />
                        <Helper:InfoTextBox Text="{Binding KCal, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding KCalValid,Mode=TwoWay}" InputType="DecimalNotNull" Margin="1,0,0,0" TextBoxInfo="KCal"  Width="{Binding ElementName=Col2, Path=Width}" />
                        <Helper:InfoTextBox Text="{Binding Fat, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding FatValid,Mode=TwoWay}" InputType="DecimalNotNull" Margin="1,0,0,0" TextBoxInfo="{Loc FettLbl}"  Width="{Binding ElementName=Col3, Path=Width}"  />
                        <Helper:InfoTextBox Text="{Binding Kh, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding KhValid,Mode=TwoWay}" InputType="DecimalNotNull" Margin="1,0,0,0" TextBoxInfo="{Loc KhLbl}"  Width="{Binding ElementName=Col4, Path=Width}"  />
                        <Helper:InfoTextBox Text="{Binding Eiweiß, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding EiweißValid,Mode=TwoWay}" InputType="DecimalNotNull" Margin="1,0,0,0" TextBoxInfo="{Loc EiweißLbl}"  Width="{Binding ElementName=Col5, Path=Width}" />

                        <ComboBox ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategorie,Mode=TwoWay}" Margin="1,0,0,0" Width="{Binding ElementName=Col6, Path=Width}" Visibility="{Binding CatComboBox,Converter={Helper:BooleanToVisibilityConverterCol}}"></ComboBox>
                        <Helper:InfoTextBox Text="{Binding Rubrik, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsValid="{Binding RubrikValid,Mode=TwoWay}" InputType="TextNotNull" Margin="1,0,0,0" Width="{Binding ElementName=Col6, Path=Width}" Visibility="{Binding CatTextBox,Converter={Helper:BooleanToVisibilityConverterCol}}" TextBoxInfo="{Loc NewCat}" />

                        <TextBox IsReadOnly="True" Margin="1,0,0,0" Text="..."  Width="{Binding ElementName=Col7, Path=Width}" ToolTip="{Loc WWTxtBox}" />
                        <Button Margin="2,0,0,0" Width="25" Height="25" ToolTip="{Loc SmallAddCatBtn}" Command="{Binding AddCatToggle}">
                            <Button.Content>
                                <Image Style="{StaticResource toolbarImageStyle}" Source="pack://application:,,,/Images/Add.png"></Image>
                            </Button.Content>
                        </Button>
                        <Button Margin="2,0,0,0" Width="25" Height="25" ToolTip="{Loc SmallAddBtn}" Command="{Binding AddFood}">
                            <Button.Content>
                                <Image Style="{StaticResource toolbarImageStyle}" Source="pack://application:,,,/Images/file_add.png"></Image>
                            </Button.Content>
                        </Button>
                        <Button Margin="10,0,0,0" Width="25" Height="25" ToolTip="{Loc SmallDeleteBtn}" Command="{Binding DelFood}">
                            <Button.Content>
                                <Image Style="{StaticResource toolbarImageStyle}" Source="pack://application:,,,/Images/file_delete.png"></Image>
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </Helper:Reveal>
            </Grid>
        </Border>
        <Border Grid.Row="1" Margin="3" BorderBrush="GhostWhite" BorderThickness="1" CornerRadius="10">
            <Grid Height="Auto">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <StackPanel Margin="0,5,0,10" VerticalAlignment="Center" Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
                    <Label Margin="5,0,0,0" Content="{Binding WeightOfDay}"></Label>
                    <Label Margin="5,0,0,0" Content="{Binding CalOfDay}"></Label>
                    <Label Margin="5,0,0,0" Content="{Binding WWOfDay}"></Label>
                </StackPanel>
                <StackPanel VerticalAlignment="Center" Grid.Column="1" Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
                    <RadioButton Margin="5"  Content="{Loc BreakfastRB}" IsChecked="{Binding Type, Converter={Helper:EnumToBoolConverter},   
                                                                                    ConverterParameter={x:Static Helper:FoodType.Breakfast}, Mode=TwoWay}" GroupName="1"></RadioButton>
                    <RadioButton Margin="5"  Content="{Loc LunchRB}" IsChecked="{Binding Type, Converter={Helper:EnumToBoolConverter},   
                                                                                    ConverterParameter={x:Static Helper:FoodType.Lunch}, Mode=TwoWay}" GroupName="2"></RadioButton>
                    <RadioButton Margin="5"  Content="{Loc DinnerRB}" IsChecked="{Binding Type, Converter={Helper:EnumToBoolConverter},   
                                                                                    ConverterParameter={x:Static Helper:FoodType.Dinner}, Mode=TwoWay}" GroupName="3"></RadioButton>
                    <RadioButton Margin="5"  Content="{Loc ElseRB}" IsChecked="{Binding Type, Converter={Helper:EnumToBoolConverter},   
                                                                                    ConverterParameter={x:Static Helper:FoodType.Else}, Mode=TwoWay}" GroupName="4"></RadioButton>
                </StackPanel>
                <ListView Grid.Row="2"
                              Margin="6,6,6,1"
                              Grid.ColumnSpan="2"
                              IsSynchronizedWithCurrentItem="True"
                              ItemsSource="{Binding UserFoods}" 
                              SelectedItem="{Binding SelectedUserFood, Mode=TwoWay}" 
                              SelectionMode="Single"
                              SelectionChanged="ListView_SelectionChanged">
                    <ListView.View>
                        <GridView AllowsColumnReorder="False">
                            <GridViewColumn x:Name="UserCol1" Header="{Loc NahrungsmittelLbl}"  Width="170" DisplayMemberBinding="{Binding Item}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol2" Header="{Loc MengeLbl}"  Width="70" DisplayMemberBinding="{Binding Menge}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol3" Header="KCal"  Width="60" DisplayMemberBinding="{Binding Kal}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol4" Header="{Loc FettLbl}"  Width="60" DisplayMemberBinding="{Binding Fett}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol5" Header="{Loc KhLbl}"  Width="60" DisplayMemberBinding="{Binding Kh}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol6" Header="{Loc EiweißLbl}"  Width="60" DisplayMemberBinding="{Binding Eiweiss}"></GridViewColumn>
                            <GridViewColumn x:Name="UserCol7" Header="WWPoints"  Width="60" DisplayMemberBinding="{Binding WWPoints}"></GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
                <Helper:Reveal IsExpanded="{Binding UserEditVisibility}" Margin="5,0,3,3" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left">
                    <StackPanel  Orientation="Horizontal">
                        <Helper:InfoTextBox Text="{Binding ChangeItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True"  Margin="1,0,0,0" Width="{Binding ElementName=UserCol1, Path=Width}" />
                        <Helper:InfoTextBox Text="{Binding ChangeAmount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  InputType="IntNotNull" IsValid="{Binding ChangeAmountValid, Mode=TwoWay}" Margin="1,0,0,0" Width="{Binding ElementName=UserCol2, Path=Width}" ToolTip="Change Amount to Calculate..."/>
                        <Helper:InfoTextBox Text="{Binding ChangeKCal, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="1,0,0,0"  Width="{Binding ElementName=UserCol3, Path=Width}"  />
                        <Helper:InfoTextBox Text="{Binding ChangeFat, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="1,0,0,0"   Width="{Binding ElementName=UserCol4, Path=Width}"  />
                        <Helper:InfoTextBox Text="{Binding ChangeKh, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="1,0,0,0" Width="{Binding ElementName=UserCol5, Path=Width}" />
                        <Helper:InfoTextBox Text="{Binding ChangeEiweiß, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Margin="1,0,0,0" Width="{Binding ElementName=UserCol6, Path=Width}" />
                        <Helper:InfoTextBox Text="{Binding ChangeWWPoints, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True"  Margin="1,0,0,0" Width="{Binding ElementName=UserCol7, Path=Width}" />
                        <Button ToolTipService.ShowOnDisabled="True" Margin="2,0,0,0" Width="25" Height="25" ToolTip="{Loc SmallUpdateUserDBBtn}" Command="{Binding UpdateUserDB}">
                            <Button.Content>
                                <Image Style="{StaticResource toolbarImageStyle}" Source="pack://application:,,,/Images/file_edit.png"></Image>
                            </Button.Content>
                        </Button>
                        <Button ToolTipService.ShowOnDisabled="True" Margin="10,0,0,0" Width="25" Height="25" ToolTip="{Loc SmallDeleteUserDBBtn}" Command="{Binding DeleteUserDB}">
                            <Button.Content>
                                <Image Style="{StaticResource toolbarImageStyle}" Source="pack://application:,,,/Images/file_delete.png"></Image>
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </Helper:Reveal>
            </Grid>
        </Border>
    </Grid>
</Page>
